#!/bin/sh
# Prepares finalpackage for distribution.
# This script is ment to be run from the ../tools directory!

OUTPUT=../release
TMP=$OUTPUT/tmp

# Clean/create the distribution directory
if [ -d "$OUTPUT" ]; then
    echo 'Cleaning previous build'
    rm -rf $OUTPUT
fi

# Create the output directory
echo 'Creating output directory'
mkdir $OUTPUT

# Create a temporary folder to keep all of our needed files
mkdir $TMP

# Copy root-level files
cp ../install.xml $TMP/install.xml

# Copy admin, site
echo 'moving files...'
rsync -a -e -v --exclude=*.svn/ ../admin $TMP
rsync -a -e -v --exclude=*.svn/ ../site $TMP

echo 'creating package...'
cd $TMP
zip -r ../musashi.zip *

# cleanup
echo 'removing temporary directory'
cd ..
rm -rf tmp


echo 'done'